import os,django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_demo.settings.offline_config")
django.setup()
import jwt
from user import models
from django.contrib.auth import authenticate
from django.contrib.auth.hashers import check_password
#
# q=jwt.encode({'1':"123"},'123').decode('utf-8')
# print(q)
# z=jwt.decode(q,'123')
# print(z)

# credentials = {
#             'username': 'admin123',
#             'password': '110120xl'
#         }
# if credentials.values():
#
#     user=authenticate(**credentials)
#     print(user.mobile,1)

from elasticsearch import Elasticsearch

obj = Elasticsearch(["127.0.0.1:9200"])
obj.indices.delete(index='book',ignore=[400,404])
# obj.create(index='book',doc_type="_doc",id=1,body={
#   "results": [
#         {
#             "name": "supervisor",
#             "cover": "http://127.0.0.1:8000/media/cover/supervisor.png",
#             "cumulative_clicks": 0,
#             "release_time": "2020-04-19",
#             "sharer": {
#                 "name": "陈鸿龙",
#                 "title": "python初级开发工程师",
#                 "user": {
#                     "first_name": "乔瑟夫",
#                     "last_name": "乔斯达",
#                     "icon": "http://127.0.0.1:8000/media/icon/default.jpg"
#                 },
#                 "presentation": "罗马不是一天建成的，他需要不断的积累和雕琢才能走向辉煌。趁自己还年轻多去看多去学，去完成自己想要做的事就足够了。"
#             },
#             "id": 1,
#             "detail_page": {
#                 "video_link": "http://q9tekw2j2.bkt.clouddn.com/default.mp4",
#                 "faq": "无法决定进程的开启顺序，如果A进程需要先开B进程支持，在同时异常退出的情况下，他无法决定A进程先重启还是B进程先重启。;若一个进程一直崩溃，而它如果能产生一些文件的话，那些文件会因为循环重启循环生成一直消耗资源。",
#                 "document_link": "http://q9tekw2j2.bkt.clouddn.com/Supervisor%E9%83%A8%E7%BD%B2%E6%96%87%E6%A1%A3.pdf;http://q9tekw2j2.bkt.clouddn.com/supervisro.pptx",
#                 "vcs": "http://q9tekw2j2.bkt.clouddn.com/Default.jpg"
#             }
#         }
#     ]
# })
import re

z=re.findall('^[0-9]{4}','2019/03/05')
print(z)